﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.IsolatedStorage;
using System.IO;
using System.Security.Permissions;


/// MSDN article about isolated storege: http://msdn.microsoft.com/en-us/library/ff431811(v=vs.92).aspx

namespace PoiBrowser
{

    [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
    [System.Runtime.InteropServices.ComVisibleAttribute(true)]
    public partial class frmBrowser : Form
    {
        Engine.POI.PoiList l;
        public frmBrowser()
        {
            InitializeComponent();
            WindowState = FormWindowState.Maximized;
            
            browser.LoadMap(Engine.CustomControls.WebMap.MapType.Google);            

            l = new Engine.POI.PoiList();
            Engine.PoiReader reader = new Engine.PoiReader();
            l.AddRange((Engine.POI.BasePoi[])reader.Load("Speedcam.txt"));
            poiGridView1.map = browser;  
            this.poiGridView1.Load(l);
                      
            browser.DocumentCompleted+=new WebBrowserDocumentCompletedEventHandler(browser_DocumentCompleted);

        }



        private void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //browser.loadPOIs(l);
        }

        public Uri LoadPageFromDisk(string filePath)
        {
            Uri targetPage = null;

            string workingPageURI = filePath.Trim();

            workingPageURI = Path.GetFullPath(workingPageURI);

            if (Uri.TryCreate(workingPageURI, UriKind.RelativeOrAbsolute, out targetPage) == true)
            {

                return targetPage;
            }
            return null;

        }
    }


   
}
